<?php
use yii\helpers\Url;
\backend\assets\PickerAsset::register($this);
?>
<?php $this->beginBlock('content') ?>
<div class="row">
   <div class="col-sm-12">
        <div class="white-box">
            <h3 class="box-title"></h3>
            <div class="row m-b-15">
                <div class="col-sm-10">
                    <form action="">
                        <div class="row">
                            <div class="col-sm-4">
                                <div class="form-group">
                                    <div class="input-daterange input-group" id="date-range">
                                        <input type="text" class="form-control" name="time_start"  rel-type="date" value="<?=Yii::$app->request->get('time_start')?>" placeholder="开始时间" autocomplete="off" />
                                        <span class="input-group-addon bg-info b-0 text-white">to</span>
                                        <input type="text" class="form-control" name="time_end"  rel-type="date" value="<?=Yii::$app->request->get('time_end')?>" placeholder="结束时间" autocomplete="off" />
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="form-group">
                                    <select class="selectpicker" data-live-search="true" name="key">
                                        <option value=""></option>
                                        <option value="agent_uid">代理商id</option>
                                        <option value="agent_account">代理商账号</option>
                                        <option value="agent_name">代理商名称</option>
                                        <option value="manager_name">区域经理名称</option>

                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <input type="text" class="form-control m-r-5" name="val" value="<?=Yii::$app->request->get('val')?>" placeholder="">
                            </div>
                            <div class="col-sm-2">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" type="submit">
                                            搜索
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
            <div>合计终端数：<?=intval(@$totalRet["terminal_num"])?></div>
            <br>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>时间</th>
                        <th>终端数</th>
                        <th>代理名称</th>
                        <th>区域经理</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($ret as $item): ?>
                    <tr>
                        <td><?=$item["created_date"]?></td>
                        <td><?=$item["upper_num"]?></td>
                        <td>
                            <?=$item["agentInfo"]["name"]?>
                        </td>
                        <td>
                            <?=$item["managerInfo"]["name"]?>
                        </td>
                        <td>
                            <a href="<?=Url::to([
                                'detail-area',
                                'agent_id' => $item['agent_id'],
                                'manager_id' => $item['manager_id'],
                                'time_start' => $item["created_date"],
                                'time_end' => $item["created_date"],
                            ])?>" rel-height="80%" data-toggle="tooltip" data-original-title="查看地区数据" rel-action="open"> 查看地区数据 </a>
                            <?php if ($item["parent_agent"] == 0) : ?>
                                <a rel-width="100%" rel-height="90%" rel-action="open" href="<?=Url::to(["index", "parent_agent" => $item["agent_id"], "created_date" => $item["created_date"], "manager_id" => $item["manager_id"]])?>">查看下级代理数据</a>
                            <?php endif ?>
                        </td>
                        </td>
                    </tr>
                    <?php endforeach ?>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="14" class="footable-visible">
                            <div class="text-right">
                                <?=\common\components\DataHelper::getLinkPager($page)?>
                            </div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $this->endBlock()?>
